def f(a, b):
    c = 1
    s = {}
    while 1:
        while a < b:
            a *= 10
        a = a % b
        if a == 0:
            return 0
        if a in s:
            return c
        s[a] = 1
        c += 1

ans = 0
num = 0
for i in xrange(1, 1000):
    n = f(1, i)
    if ans < n:
        ans = n
        num = i
    print i, n

print num
